import { FC,useEffect, useState } from 'react';
import { useNavigate } from 'react-router';
import {useSelector, useDispatch} from 'react-redux'

const Index: FC<any> = (props:any): JSX.Element => {

  const dispatch= useDispatch();

  const token= useSelector((state:any)=>state.token);
  const userInfo= useSelector((state:any)=>state.userInfo);
  const update=()=>{
    
       dispatch({type:"UPDATETOKEN",val:"mmmmmmmm"});
  }
  const update2=()=>{
    
    dispatch({type:"UPDATENAME",val:"李四"});
}

    useEffect(()=>{
    },[])

    return (
      <div>redux

        {token}
        {userInfo.name}

        <button onClick={update}>修改</button>
        <button onClick={update2}>修改2</button>
      </div>
    )
}
export default Index;